################################ MACROS ################################
#
# DOC: the document
# FIG: directory for figures
# BIB: bibliography database
# BST: bibliography style
# SEL: selected pages; e.g., "odd", "even", "2\:4,6"
#
DOC = icra12
FIGDIR = figs
BIBDIR= references

############################### PROGRAMS ###############################
#
TEX = latex
BIBTEX = bibtex -min-crossrefs=100 
DVIPS = dvips -ta4 -Ppdf -G0
#changing prepress to screen produces much smaller files 
#PS2PDF = ps2pdf 
PS2PDF = gs -sOutputFile=$(DOC).pdf -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -r600 -dPDFSETTINGS=/prepress -dSubsetFonts=true -dMaxSubsetPct=100 -dEmbedAllFonts=true -dEncodeGrayImages=true -dEncodeColorImages=true
PRINT = lpr -Plaser0
RM = rm -f
MAKE = make 

########################################################################

pdf:	ps 
	$(PS2PDF) $(DOC).ps > $(DOC).pdf

aux:    figures bibliography $(DOC).tex 
	$(TEX) $(DOC).tex

bib:    aux 
	$(BIBTEX) $(DOC)

dvi:    aux bib 
	$(TEX) $(DOC).tex
	$(TEX) $(DOC).tex

ps:     dvi
	$(DVIPS) -o $(DOC).ps $(DOC).dvi

figures:
	$(MAKE) -C $(FIGDIR)
	
bibliography:
	$(MAKE) -C $(BIBDIR)

clean:
	$(RM) $(DOC).aux $(DOC).log
	$(RM) $(DOC).toc $(DOC).lot $(DOC).lof
	$(RM) $(DOC).ttt $(DOC).lot $(DOC).fff
	$(RM) $(DOC).blg $(DOC).out
	$(RM) $(DOC).dvi $(DOC)-*.dvi
	$(RM) $(DOC).ps $(DOC)-*.ps
	$(RM) $(DOC).tex.backup
	$(RM) $(DOC).tex.bak
	$(RM) $(DOC).bbl
	$(RM) $(DOC).pdf
	$(RM) $(DOC).tex~
	$(RM) Makefile~
	$(MAKE) -C $(FIGDIR) clean
	$(MAKE) -C $(BIBDIR) clean
